package com.wwu.system.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.wwu.common.constant.CommConst;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 系统登陆日志实体
 * @author 一蓑烟雨
 * @date 2023/5/31 9:35
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("SysLoginLog")
@ApiModel(value="SysLoginLog:系统登陆日志实体", description="系统登陆日志实体")
public class SysLoginLog implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "记录流水号")
    @TableId(value = "record_id", type = IdType.ASSIGN_ID)
    private String recordId;

    @ApiModelProperty(value = "登陆名")
    @TableField("user_name")
    private String userName;

    @ApiModelProperty(value = "用户昵称")
    @TableField("nickName")
    private String nick_name;

    @ApiModelProperty(value = "IP地址")
    @TableField("login_ip")
    private String loginIp;

    @ApiModelProperty(value = "登陆内容")
    @TableField("login_desc")
    private String loginDesc;

    @ApiModelProperty(value = "登陆状态(0:成功；1:失败)）")
    @TableField("login_status")
    private Integer loginStatus;

    @ApiModelProperty(value = "登陆位置")
    @TableField("location_desc")
    private String locationDesc;

    @ApiModelProperty(value = "删除状态(0:逻辑未删除；1:逻辑已删除)")
    @TableField("del_flag")
    @TableLogic
    private Integer delFlag;

    @ApiModelProperty(value = "创建时间")
    //格式化后台和前端显示样式
    @DateTimeFormat(pattern = CommConst.DATE_TIME)
    @JsonFormat(pattern = CommConst.DATE_TIME,timezone = CommConst.TIME_ZONE)
    /** 解决redis缓存序列化LocalDateTime问题 */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;
}
